
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 11/28/2011 00:20:11
-- Generated from EDMX file: C:\Projetos\TCC\SeguradoraIA\SeguradoraIA\Diagrama\Modelo.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [SeguradoraIA];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_BairroDeParaBairro]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[DeParaBairro] DROP CONSTRAINT [FK_BairroDeParaBairro];
GO
IF OBJECT_ID(N'[dbo].[FK_BairroPerfil]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Perfil] DROP CONSTRAINT [FK_BairroPerfil];
GO
IF OBJECT_ID(N'[dbo].[FK_CursoFormacaoDeParaCursoFormacao]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[DeParaCursoFormacao] DROP CONSTRAINT [FK_CursoFormacaoDeParaCursoFormacao];
GO
IF OBJECT_ID(N'[dbo].[FK_CursoFormacaoPerfil]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Perfil] DROP CONSTRAINT [FK_CursoFormacaoPerfil];
GO
IF OBJECT_ID(N'[dbo].[FK_MarcaCarroDeParaMarcaCarro]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[DeParaMarcaCarro] DROP CONSTRAINT [FK_MarcaCarroDeParaMarcaCarro];
GO
IF OBJECT_ID(N'[dbo].[FK_ProfissaoDeParaProfissao]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[DeParaProfissao] DROP CONSTRAINT [FK_ProfissaoDeParaProfissao];
GO
IF OBJECT_ID(N'[dbo].[FK_GrauInstrucaoPerfil]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Perfil] DROP CONSTRAINT [FK_GrauInstrucaoPerfil];
GO
IF OBJECT_ID(N'[dbo].[FK_IdadePerfil]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Perfil] DROP CONSTRAINT [FK_IdadePerfil];
GO
IF OBJECT_ID(N'[dbo].[FK_MarcaCarroPerfil]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Perfil] DROP CONSTRAINT [FK_MarcaCarroPerfil];
GO
IF OBJECT_ID(N'[dbo].[FK_ProfissaoPerfil]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Perfil] DROP CONSTRAINT [FK_ProfissaoPerfil];
GO
IF OBJECT_ID(N'[dbo].[FK_ResultadoEsperadoPerfil]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Perfil] DROP CONSTRAINT [FK_ResultadoEsperadoPerfil];
GO
IF OBJECT_ID(N'[dbo].[FK_SinistroPerfil]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Perfil] DROP CONSTRAINT [FK_SinistroPerfil];
GO
IF OBJECT_ID(N'[dbo].[FK_TempoHabilitacaoPerfil]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Perfil] DROP CONSTRAINT [FK_TempoHabilitacaoPerfil];
GO
IF OBJECT_ID(N'[dbo].[FK_TipoCarroPerfil]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Perfil] DROP CONSTRAINT [FK_TipoCarroPerfil];
GO
IF OBJECT_ID(N'[dbo].[FK_ValorCarroPerfil]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Perfil] DROP CONSTRAINT [FK_ValorCarroPerfil];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Bairro]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Bairro];
GO
IF OBJECT_ID(N'[dbo].[CursoFormacao]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CursoFormacao];
GO
IF OBJECT_ID(N'[dbo].[DeParaBairro]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DeParaBairro];
GO
IF OBJECT_ID(N'[dbo].[DeParaCursoFormacao]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DeParaCursoFormacao];
GO
IF OBJECT_ID(N'[dbo].[DeParaIdade]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DeParaIdade];
GO
IF OBJECT_ID(N'[dbo].[DeParaMarcaCarro]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DeParaMarcaCarro];
GO
IF OBJECT_ID(N'[dbo].[DeParaProfissao]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DeParaProfissao];
GO
IF OBJECT_ID(N'[dbo].[DeParaSinistro]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DeParaSinistro];
GO
IF OBJECT_ID(N'[dbo].[DeParaTempoHabilitacao]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DeParaTempoHabilitacao];
GO
IF OBJECT_ID(N'[dbo].[DeParaValorCarro]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DeParaValorCarro];
GO
IF OBJECT_ID(N'[dbo].[GrauInstrucao]', 'U') IS NOT NULL
    DROP TABLE [dbo].[GrauInstrucao];
GO
IF OBJECT_ID(N'[dbo].[Idade]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Idade];
GO
IF OBJECT_ID(N'[dbo].[LogCarga]', 'U') IS NOT NULL
    DROP TABLE [dbo].[LogCarga];
GO
IF OBJECT_ID(N'[dbo].[MarcaCarro]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MarcaCarro];
GO
IF OBJECT_ID(N'[dbo].[Perfil]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Perfil];
GO
IF OBJECT_ID(N'[dbo].[Peso]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Peso];
GO
IF OBJECT_ID(N'[dbo].[Profissao]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Profissao];
GO
IF OBJECT_ID(N'[dbo].[ResultadoEsperado]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ResultadoEsperado];
GO
IF OBJECT_ID(N'[dbo].[Sinistro]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Sinistro];
GO
IF OBJECT_ID(N'[dbo].[TempoHabilitacao]', 'U') IS NOT NULL
    DROP TABLE [dbo].[TempoHabilitacao];
GO
IF OBJECT_ID(N'[dbo].[TipoCarro]', 'U') IS NOT NULL
    DROP TABLE [dbo].[TipoCarro];
GO
IF OBJECT_ID(N'[dbo].[ValorCarro]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ValorCarro];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Bairro'
CREATE TABLE [dbo].[Bairro] (
    [IdBairro] int IDENTITY(1,1) NOT NULL,
    [Descricao] nvarchar(200)  NOT NULL
);
GO

-- Creating table 'CursoFormacao'
CREATE TABLE [dbo].[CursoFormacao] (
    [IdCursoFormacao] int IDENTITY(1,1) NOT NULL,
    [Descricao] nvarchar(200)  NOT NULL
);
GO

-- Creating table 'DeParaBairro'
CREATE TABLE [dbo].[DeParaBairro] (
    [IdDeParaBairro] int IDENTITY(1,1) NOT NULL,
    [Descricao] nvarchar(200)  NOT NULL,
    [IdBairro] int  NOT NULL
);
GO

-- Creating table 'DeParaCursoFormacao'
CREATE TABLE [dbo].[DeParaCursoFormacao] (
    [IdDeParaCursoFormacao] int IDENTITY(1,1) NOT NULL,
    [Descricao] nvarchar(200)  NOT NULL,
    [IdCursoFormacao] int  NOT NULL
);
GO

-- Creating table 'DeParaIdade'
CREATE TABLE [dbo].[DeParaIdade] (
    [IdDeParaIdade] int  NOT NULL,
    [Descricao] nchar(200)  NOT NULL,
    [IdIdade] int  NOT NULL
);
GO

-- Creating table 'DeParaMarcaCarro'
CREATE TABLE [dbo].[DeParaMarcaCarro] (
    [IdDeParaMarcaCarro] int IDENTITY(1,1) NOT NULL,
    [Descricao] nvarchar(200)  NOT NULL,
    [IdMarcaCarro] int  NOT NULL
);
GO

-- Creating table 'DeParaProfissao'
CREATE TABLE [dbo].[DeParaProfissao] (
    [IdDeParaProfissao] int IDENTITY(1,1) NOT NULL,
    [Descricao] nvarchar(200)  NOT NULL,
    [ProfissaoIdProfissao] int  NOT NULL
);
GO

-- Creating table 'DeParaSinistro'
CREATE TABLE [dbo].[DeParaSinistro] (
    [IdDeParaSinistro] int  NOT NULL,
    [Descricao] nchar(200)  NOT NULL,
    [IdSinistro] int  NOT NULL
);
GO

-- Creating table 'DeParaTempoHabilitacao'
CREATE TABLE [dbo].[DeParaTempoHabilitacao] (
    [IdDeParaTempoHabilitacao] int  NOT NULL,
    [Descricao] nchar(200)  NOT NULL,
    [IdTempoHabilitacao] int  NOT NULL
);
GO

-- Creating table 'DeParaValorCarro'
CREATE TABLE [dbo].[DeParaValorCarro] (
    [IdDeParaValorCarro] int  NOT NULL,
    [Descricao] nchar(200)  NOT NULL,
    [IdValorCarro] int  NOT NULL
);
GO

-- Creating table 'GrauInstrucao'
CREATE TABLE [dbo].[GrauInstrucao] (
    [IdGrauInstrucao] int IDENTITY(1,1) NOT NULL,
    [Descricao] nvarchar(200)  NOT NULL
);
GO

-- Creating table 'Idade'
CREATE TABLE [dbo].[Idade] (
    [IdIdade] int IDENTITY(1,1) NOT NULL,
    [Descricao] nvarchar(200)  NOT NULL,
    [IdadeInicial] bigint  NOT NULL,
    [IdadeFinal] bigint  NOT NULL
);
GO

-- Creating table 'LogCarga'
CREATE TABLE [dbo].[LogCarga] (
    [IdLogCarga] int IDENTITY(1,1) NOT NULL,
    [NomeArquivo] nvarchar(200)  NOT NULL,
    [DataHoraInicio] datetime  NOT NULL,
    [DataHoraFim] datetime  NULL,
    [QtdRegistros] bigint  NOT NULL,
    [QtdCarregados] bigint  NOT NULL,
    [QtdRejeitados] bigint  NOT NULL
);
GO

-- Creating table 'MarcaCarro'
CREATE TABLE [dbo].[MarcaCarro] (
    [IdMarcaCarro] int IDENTITY(1,1) NOT NULL,
    [Descricao] nvarchar(200)  NOT NULL
);
GO

-- Creating table 'Perfil'
CREATE TABLE [dbo].[Perfil] (
    [IdPerfil] int IDENTITY(1,1) NOT NULL,
    [IdIdade] int  NOT NULL,
    [IdValorCarro] int  NOT NULL,
    [IdBairro] int  NOT NULL,
    [IdSinistro] int  NOT NULL,
    [IdTempoHabilitacao] int  NOT NULL,
    [IdProfissao] int  NOT NULL,
    [IdGrauInstrucao] int  NOT NULL,
    [IdTipoCarro] int  NOT NULL,
    [IdMarcaCarro] int  NOT NULL,
    [IdCursoFormacao] int  NOT NULL,
    [IdResultadoEsperado] int  NOT NULL
);
GO

-- Creating table 'Peso'
CREATE TABLE [dbo].[Peso] (
    [IdPeso] int IDENTITY(1,1) NOT NULL,
    [PesoIdade] float  NOT NULL,
    [PesoValorCarro] float  NOT NULL,
    [PesoBairro] float  NOT NULL,
    [PesoSinistro] float  NOT NULL,
    [PesoTempoHabilitacao] float  NOT NULL,
    [PesoProfissao] float  NOT NULL,
    [PesoGrauInstrucao] float  NOT NULL,
    [PesoTipoCarro] float  NOT NULL,
    [PesoMarcaCarro] float  NOT NULL,
    [PesoCursoFormacao] float  NOT NULL
);
GO

-- Creating table 'Profissao'
CREATE TABLE [dbo].[Profissao] (
    [IdProfissao] int IDENTITY(1,1) NOT NULL,
    [Descricao] nvarchar(200)  NOT NULL
);
GO

-- Creating table 'ResultadoEsperado'
CREATE TABLE [dbo].[ResultadoEsperado] (
    [IdResultadoEsperado] int IDENTITY(1,1) NOT NULL,
    [Descricao] nvarchar(200)  NOT NULL
);
GO

-- Creating table 'Sinistro'
CREATE TABLE [dbo].[Sinistro] (
    [IdSinistro] int IDENTITY(1,1) NOT NULL,
    [Descricao] nvarchar(200)  NOT NULL,
    [MesInicial] bigint  NULL,
    [MesFinal] bigint  NULL
);
GO

-- Creating table 'TempoHabilitacao'
CREATE TABLE [dbo].[TempoHabilitacao] (
    [IdTempoHabilitacao] int IDENTITY(1,1) NOT NULL,
    [Descricao] nvarchar(200)  NOT NULL,
    [AnoInicial] bigint  NOT NULL,
    [AnoFinal] bigint  NOT NULL
);
GO

-- Creating table 'TipoCarro'
CREATE TABLE [dbo].[TipoCarro] (
    [IdTipoCarro] int IDENTITY(1,1) NOT NULL,
    [Descricao] nvarchar(200)  NOT NULL
);
GO

-- Creating table 'ValorCarro'
CREATE TABLE [dbo].[ValorCarro] (
    [IdValorCarro] int IDENTITY(1,1) NOT NULL,
    [Descricao] nvarchar(200)  NOT NULL,
    [ValorInicial] float  NOT NULL,
    [ValorFinal] float  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [IdBairro] in table 'Bairro'
ALTER TABLE [dbo].[Bairro]
ADD CONSTRAINT [PK_Bairro]
    PRIMARY KEY CLUSTERED ([IdBairro] ASC);
GO

-- Creating primary key on [IdCursoFormacao] in table 'CursoFormacao'
ALTER TABLE [dbo].[CursoFormacao]
ADD CONSTRAINT [PK_CursoFormacao]
    PRIMARY KEY CLUSTERED ([IdCursoFormacao] ASC);
GO

-- Creating primary key on [IdDeParaBairro] in table 'DeParaBairro'
ALTER TABLE [dbo].[DeParaBairro]
ADD CONSTRAINT [PK_DeParaBairro]
    PRIMARY KEY CLUSTERED ([IdDeParaBairro] ASC);
GO

-- Creating primary key on [IdDeParaCursoFormacao] in table 'DeParaCursoFormacao'
ALTER TABLE [dbo].[DeParaCursoFormacao]
ADD CONSTRAINT [PK_DeParaCursoFormacao]
    PRIMARY KEY CLUSTERED ([IdDeParaCursoFormacao] ASC);
GO

-- Creating primary key on [IdDeParaIdade] in table 'DeParaIdade'
ALTER TABLE [dbo].[DeParaIdade]
ADD CONSTRAINT [PK_DeParaIdade]
    PRIMARY KEY CLUSTERED ([IdDeParaIdade] ASC);
GO

-- Creating primary key on [IdDeParaMarcaCarro] in table 'DeParaMarcaCarro'
ALTER TABLE [dbo].[DeParaMarcaCarro]
ADD CONSTRAINT [PK_DeParaMarcaCarro]
    PRIMARY KEY CLUSTERED ([IdDeParaMarcaCarro] ASC);
GO

-- Creating primary key on [IdDeParaProfissao] in table 'DeParaProfissao'
ALTER TABLE [dbo].[DeParaProfissao]
ADD CONSTRAINT [PK_DeParaProfissao]
    PRIMARY KEY CLUSTERED ([IdDeParaProfissao] ASC);
GO

-- Creating primary key on [IdDeParaSinistro] in table 'DeParaSinistro'
ALTER TABLE [dbo].[DeParaSinistro]
ADD CONSTRAINT [PK_DeParaSinistro]
    PRIMARY KEY CLUSTERED ([IdDeParaSinistro] ASC);
GO

-- Creating primary key on [IdDeParaTempoHabilitacao] in table 'DeParaTempoHabilitacao'
ALTER TABLE [dbo].[DeParaTempoHabilitacao]
ADD CONSTRAINT [PK_DeParaTempoHabilitacao]
    PRIMARY KEY CLUSTERED ([IdDeParaTempoHabilitacao] ASC);
GO

-- Creating primary key on [IdDeParaValorCarro] in table 'DeParaValorCarro'
ALTER TABLE [dbo].[DeParaValorCarro]
ADD CONSTRAINT [PK_DeParaValorCarro]
    PRIMARY KEY CLUSTERED ([IdDeParaValorCarro] ASC);
GO

-- Creating primary key on [IdGrauInstrucao] in table 'GrauInstrucao'
ALTER TABLE [dbo].[GrauInstrucao]
ADD CONSTRAINT [PK_GrauInstrucao]
    PRIMARY KEY CLUSTERED ([IdGrauInstrucao] ASC);
GO

-- Creating primary key on [IdIdade] in table 'Idade'
ALTER TABLE [dbo].[Idade]
ADD CONSTRAINT [PK_Idade]
    PRIMARY KEY CLUSTERED ([IdIdade] ASC);
GO

-- Creating primary key on [IdLogCarga] in table 'LogCarga'
ALTER TABLE [dbo].[LogCarga]
ADD CONSTRAINT [PK_LogCarga]
    PRIMARY KEY CLUSTERED ([IdLogCarga] ASC);
GO

-- Creating primary key on [IdMarcaCarro] in table 'MarcaCarro'
ALTER TABLE [dbo].[MarcaCarro]
ADD CONSTRAINT [PK_MarcaCarro]
    PRIMARY KEY CLUSTERED ([IdMarcaCarro] ASC);
GO

-- Creating primary key on [IdPerfil] in table 'Perfil'
ALTER TABLE [dbo].[Perfil]
ADD CONSTRAINT [PK_Perfil]
    PRIMARY KEY CLUSTERED ([IdPerfil] ASC);
GO

-- Creating primary key on [IdPeso] in table 'Peso'
ALTER TABLE [dbo].[Peso]
ADD CONSTRAINT [PK_Peso]
    PRIMARY KEY CLUSTERED ([IdPeso] ASC);
GO

-- Creating primary key on [IdProfissao] in table 'Profissao'
ALTER TABLE [dbo].[Profissao]
ADD CONSTRAINT [PK_Profissao]
    PRIMARY KEY CLUSTERED ([IdProfissao] ASC);
GO

-- Creating primary key on [IdResultadoEsperado] in table 'ResultadoEsperado'
ALTER TABLE [dbo].[ResultadoEsperado]
ADD CONSTRAINT [PK_ResultadoEsperado]
    PRIMARY KEY CLUSTERED ([IdResultadoEsperado] ASC);
GO

-- Creating primary key on [IdSinistro] in table 'Sinistro'
ALTER TABLE [dbo].[Sinistro]
ADD CONSTRAINT [PK_Sinistro]
    PRIMARY KEY CLUSTERED ([IdSinistro] ASC);
GO

-- Creating primary key on [IdTempoHabilitacao] in table 'TempoHabilitacao'
ALTER TABLE [dbo].[TempoHabilitacao]
ADD CONSTRAINT [PK_TempoHabilitacao]
    PRIMARY KEY CLUSTERED ([IdTempoHabilitacao] ASC);
GO

-- Creating primary key on [IdTipoCarro] in table 'TipoCarro'
ALTER TABLE [dbo].[TipoCarro]
ADD CONSTRAINT [PK_TipoCarro]
    PRIMARY KEY CLUSTERED ([IdTipoCarro] ASC);
GO

-- Creating primary key on [IdValorCarro] in table 'ValorCarro'
ALTER TABLE [dbo].[ValorCarro]
ADD CONSTRAINT [PK_ValorCarro]
    PRIMARY KEY CLUSTERED ([IdValorCarro] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [IdBairro] in table 'DeParaBairro'
ALTER TABLE [dbo].[DeParaBairro]
ADD CONSTRAINT [FK_BairroDeParaBairro]
    FOREIGN KEY ([IdBairro])
    REFERENCES [dbo].[Bairro]
        ([IdBairro])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_BairroDeParaBairro'
CREATE INDEX [IX_FK_BairroDeParaBairro]
ON [dbo].[DeParaBairro]
    ([IdBairro]);
GO

-- Creating foreign key on [IdBairro] in table 'Perfil'
ALTER TABLE [dbo].[Perfil]
ADD CONSTRAINT [FK_BairroPerfil]
    FOREIGN KEY ([IdBairro])
    REFERENCES [dbo].[Bairro]
        ([IdBairro])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_BairroPerfil'
CREATE INDEX [IX_FK_BairroPerfil]
ON [dbo].[Perfil]
    ([IdBairro]);
GO

-- Creating foreign key on [IdCursoFormacao] in table 'DeParaCursoFormacao'
ALTER TABLE [dbo].[DeParaCursoFormacao]
ADD CONSTRAINT [FK_CursoFormacaoDeParaCursoFormacao]
    FOREIGN KEY ([IdCursoFormacao])
    REFERENCES [dbo].[CursoFormacao]
        ([IdCursoFormacao])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CursoFormacaoDeParaCursoFormacao'
CREATE INDEX [IX_FK_CursoFormacaoDeParaCursoFormacao]
ON [dbo].[DeParaCursoFormacao]
    ([IdCursoFormacao]);
GO

-- Creating foreign key on [IdCursoFormacao] in table 'Perfil'
ALTER TABLE [dbo].[Perfil]
ADD CONSTRAINT [FK_CursoFormacaoPerfil]
    FOREIGN KEY ([IdCursoFormacao])
    REFERENCES [dbo].[CursoFormacao]
        ([IdCursoFormacao])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CursoFormacaoPerfil'
CREATE INDEX [IX_FK_CursoFormacaoPerfil]
ON [dbo].[Perfil]
    ([IdCursoFormacao]);
GO

-- Creating foreign key on [IdMarcaCarro] in table 'DeParaMarcaCarro'
ALTER TABLE [dbo].[DeParaMarcaCarro]
ADD CONSTRAINT [FK_MarcaCarroDeParaMarcaCarro]
    FOREIGN KEY ([IdMarcaCarro])
    REFERENCES [dbo].[MarcaCarro]
        ([IdMarcaCarro])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_MarcaCarroDeParaMarcaCarro'
CREATE INDEX [IX_FK_MarcaCarroDeParaMarcaCarro]
ON [dbo].[DeParaMarcaCarro]
    ([IdMarcaCarro]);
GO

-- Creating foreign key on [ProfissaoIdProfissao] in table 'DeParaProfissao'
ALTER TABLE [dbo].[DeParaProfissao]
ADD CONSTRAINT [FK_ProfissaoDeParaProfissao]
    FOREIGN KEY ([ProfissaoIdProfissao])
    REFERENCES [dbo].[Profissao]
        ([IdProfissao])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ProfissaoDeParaProfissao'
CREATE INDEX [IX_FK_ProfissaoDeParaProfissao]
ON [dbo].[DeParaProfissao]
    ([ProfissaoIdProfissao]);
GO

-- Creating foreign key on [IdGrauInstrucao] in table 'Perfil'
ALTER TABLE [dbo].[Perfil]
ADD CONSTRAINT [FK_GrauInstrucaoPerfil]
    FOREIGN KEY ([IdGrauInstrucao])
    REFERENCES [dbo].[GrauInstrucao]
        ([IdGrauInstrucao])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_GrauInstrucaoPerfil'
CREATE INDEX [IX_FK_GrauInstrucaoPerfil]
ON [dbo].[Perfil]
    ([IdGrauInstrucao]);
GO

-- Creating foreign key on [IdIdade] in table 'Perfil'
ALTER TABLE [dbo].[Perfil]
ADD CONSTRAINT [FK_IdadePerfil]
    FOREIGN KEY ([IdIdade])
    REFERENCES [dbo].[Idade]
        ([IdIdade])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_IdadePerfil'
CREATE INDEX [IX_FK_IdadePerfil]
ON [dbo].[Perfil]
    ([IdIdade]);
GO

-- Creating foreign key on [IdMarcaCarro] in table 'Perfil'
ALTER TABLE [dbo].[Perfil]
ADD CONSTRAINT [FK_MarcaCarroPerfil]
    FOREIGN KEY ([IdMarcaCarro])
    REFERENCES [dbo].[MarcaCarro]
        ([IdMarcaCarro])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_MarcaCarroPerfil'
CREATE INDEX [IX_FK_MarcaCarroPerfil]
ON [dbo].[Perfil]
    ([IdMarcaCarro]);
GO

-- Creating foreign key on [IdProfissao] in table 'Perfil'
ALTER TABLE [dbo].[Perfil]
ADD CONSTRAINT [FK_ProfissaoPerfil]
    FOREIGN KEY ([IdProfissao])
    REFERENCES [dbo].[Profissao]
        ([IdProfissao])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ProfissaoPerfil'
CREATE INDEX [IX_FK_ProfissaoPerfil]
ON [dbo].[Perfil]
    ([IdProfissao]);
GO

-- Creating foreign key on [IdResultadoEsperado] in table 'Perfil'
ALTER TABLE [dbo].[Perfil]
ADD CONSTRAINT [FK_ResultadoEsperadoPerfil]
    FOREIGN KEY ([IdResultadoEsperado])
    REFERENCES [dbo].[ResultadoEsperado]
        ([IdResultadoEsperado])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ResultadoEsperadoPerfil'
CREATE INDEX [IX_FK_ResultadoEsperadoPerfil]
ON [dbo].[Perfil]
    ([IdResultadoEsperado]);
GO

-- Creating foreign key on [IdSinistro] in table 'Perfil'
ALTER TABLE [dbo].[Perfil]
ADD CONSTRAINT [FK_SinistroPerfil]
    FOREIGN KEY ([IdSinistro])
    REFERENCES [dbo].[Sinistro]
        ([IdSinistro])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SinistroPerfil'
CREATE INDEX [IX_FK_SinistroPerfil]
ON [dbo].[Perfil]
    ([IdSinistro]);
GO

-- Creating foreign key on [IdTempoHabilitacao] in table 'Perfil'
ALTER TABLE [dbo].[Perfil]
ADD CONSTRAINT [FK_TempoHabilitacaoPerfil]
    FOREIGN KEY ([IdTempoHabilitacao])
    REFERENCES [dbo].[TempoHabilitacao]
        ([IdTempoHabilitacao])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_TempoHabilitacaoPerfil'
CREATE INDEX [IX_FK_TempoHabilitacaoPerfil]
ON [dbo].[Perfil]
    ([IdTempoHabilitacao]);
GO

-- Creating foreign key on [IdTipoCarro] in table 'Perfil'
ALTER TABLE [dbo].[Perfil]
ADD CONSTRAINT [FK_TipoCarroPerfil]
    FOREIGN KEY ([IdTipoCarro])
    REFERENCES [dbo].[TipoCarro]
        ([IdTipoCarro])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_TipoCarroPerfil'
CREATE INDEX [IX_FK_TipoCarroPerfil]
ON [dbo].[Perfil]
    ([IdTipoCarro]);
GO

-- Creating foreign key on [IdValorCarro] in table 'Perfil'
ALTER TABLE [dbo].[Perfil]
ADD CONSTRAINT [FK_ValorCarroPerfil]
    FOREIGN KEY ([IdValorCarro])
    REFERENCES [dbo].[ValorCarro]
        ([IdValorCarro])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ValorCarroPerfil'
CREATE INDEX [IX_FK_ValorCarroPerfil]
ON [dbo].[Perfil]
    ([IdValorCarro]);
GO

-- Creating foreign key on [IdSinistro] in table 'DeParaSinistro'
ALTER TABLE [dbo].[DeParaSinistro]
ADD CONSTRAINT [FK_SinistroDeParaSinistro]
    FOREIGN KEY ([IdSinistro])
    REFERENCES [dbo].[Sinistro]
        ([IdSinistro])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_SinistroDeParaSinistro'
CREATE INDEX [IX_FK_SinistroDeParaSinistro]
ON [dbo].[DeParaSinistro]
    ([IdSinistro]);
GO

-- Creating foreign key on [IdTempoHabilitacao] in table 'DeParaTempoHabilitacao'
ALTER TABLE [dbo].[DeParaTempoHabilitacao]
ADD CONSTRAINT [FK_TempoHabilitacaoDeParaTempoHabilitacao]
    FOREIGN KEY ([IdTempoHabilitacao])
    REFERENCES [dbo].[TempoHabilitacao]
        ([IdTempoHabilitacao])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_TempoHabilitacaoDeParaTempoHabilitacao'
CREATE INDEX [IX_FK_TempoHabilitacaoDeParaTempoHabilitacao]
ON [dbo].[DeParaTempoHabilitacao]
    ([IdTempoHabilitacao]);
GO

-- Creating foreign key on [IdValorCarro] in table 'DeParaValorCarro'
ALTER TABLE [dbo].[DeParaValorCarro]
ADD CONSTRAINT [FK_ValorCarroDeParaValorCarro]
    FOREIGN KEY ([IdValorCarro])
    REFERENCES [dbo].[ValorCarro]
        ([IdValorCarro])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_ValorCarroDeParaValorCarro'
CREATE INDEX [IX_FK_ValorCarroDeParaValorCarro]
ON [dbo].[DeParaValorCarro]
    ([IdValorCarro]);
GO

-- Creating foreign key on [IdIdade] in table 'DeParaIdade'
ALTER TABLE [dbo].[DeParaIdade]
ADD CONSTRAINT [FK_IdadeDeParaIdade]
    FOREIGN KEY ([IdIdade])
    REFERENCES [dbo].[Idade]
        ([IdIdade])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_IdadeDeParaIdade'
CREATE INDEX [IX_FK_IdadeDeParaIdade]
ON [dbo].[DeParaIdade]
    ([IdIdade]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------